package com.jeeplus.netty.proto;

import io.protostuff.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.lang.reflect.Field;

public class ProtoBuffInfoBase implements Serializable
{
    private static final long serialVersionUID = 1L;


    //yanruTODO 留意这里可能比较耗费性能
//    protected Logger logger = LoggerFactory.getLogger(getClass());

//    public ProtoBuffInfoBase()
//    {
//        this.protoName = this.getClass().getName();
//        //yanruTODo 测试打印
//        System.out.println("执行默认构造，此时protoName="+this.protoName);
//    }

    //获取内容
    public String getString()
    {
        StringBuilder builder = new StringBuilder();

        Field[] fields = this.getClass().getDeclaredFields();
        for (Field field:fields) {
            field.setAccessible(true);
            try {
//                System.out.println(field.getName()+":"+field.get(this));
                builder.append(" "+ field.getName() + ":"+field.get(this));
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }

        return builder.toString();
    }

}
